package com.ycl.service.impl;

import com.github.pagehelper.PageHelper;
import com.ycl.mapper.EbNewsMapper;
import com.ycl.model.EbNews;
import com.ycl.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private EbNewsMapper ebNewsMapper;

    /**
     * 新闻分页查询
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public List<EbNews> list(Integer page,Integer pageSize){
        PageHelper.startPage(page,pageSize);
        List<EbNews> ebNews = ebNewsMapper.selectByExample(null);
        return ebNews;
    }

    @Override
    public Integer save(EbNews ebNews){
        int insert = ebNewsMapper.insert(ebNews);
        return insert;
    }

    @Override
    public EbNews selectOne(Integer enId){
        return ebNewsMapper.selectByPrimaryKey(enId);
    }

    @Override
    public Integer updateNews(EbNews ebNews){
        return ebNewsMapper.updateByPrimaryKey(ebNews);
    }
}
